﻿@using RuoVea.ExDto
@using RuoVea.OmiLog.Language
@using RuoVea.OmiLog.Attributes
@using RuoVea.OmiLog.Options
@{
    AppConfig config = ConfigManages.Config ?? new AppConfig();
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@Html.Raw(i18n.system_difference_log)</title>
    <link href="~/ruoveaui/xg6rvft8p/avue/index.css" rel="stylesheet" />
    <link href="~/ruoveaui/xg6rvft8p/elementui/index.min.css" rel="stylesheet" />
    <style> .el-button [class*="el-icon-"] + span { margin-left: 1px !important; } </style>
</head>
<body>
    <div id="app" v-cloak>
        <avue-crud :data="tableData" :option="option" :page.sync="pageOption" :table-loading="loading"
                   v-on:refresh-change="refreshChange"
                   v-on:search-change="searchChange"
                   v-on:search-reset="resetChange"
                   v-on:on-load="onLoad">
            <template slot="avatar" slot-scope="scope">
                <el-avatar shape="circle" :src="scope.row.avatar">{{scope.row.account}} </el-avatar>
            </template>

            <template slot="record" slot-scope="scope">
                <modify-record :data="scope.row"></modify-record>
            </template>
             <template slot="menuRight" slot-scope="{size}">
                <el-button icon="el-icon-delete" type="danger" circle :size="size" v-on:click="handleDeleteAll" v-if="option.clearBtn"></el-button>
              </template>
        </avue-crud>
    </div>
    <script src="~/ruoveaui/xg6rvft8p/vue/vue.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.i18n.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.lang.js"></script>
    <script>
        Vue.prototype.i18n.messages.zhCN = { ...Vue.prototype.i18n.messages.zhCN, ...{ "before_operation_record": "操作前记录", "after_operation_record": "操作后记录", "sql": "SQL", "manual_parameters": "手动传入的参数", "business_object": "业务对象", "difference_operation": "差异操作", "duration": "耗时", "creation_time": "创建时间" } };
        Vue.prototype.i18n.messages.en = { ...Vue.prototype.i18n.messages.en, ...{ "before_operation_record": "Record Before Operation", "after_operation_record": "Record After Operation", "sql": "SQL", "manual_parameters": "Manually Passed Parameters", "business_object": "Business Object", "difference_operation": "Difference Operation", "duration": "Duration", "creation_time": "Creation Time" } };
        Vue.prototype.i18n.messages.fr = { ...Vue.prototype.i18n.messages.fr, ...{"before_operation_record": "Enregistrement avant l'opération", "after_operation_record": "Enregistrement après l'opération", "sql": "SQL", "manual_parameters": "Paramètres manuellement transmis", "business_object": "Objet métier", "difference_operation": "Opération de différence", "duration": "Durée", "creation_time": "Heure de création" } };
        Vue.prototype.i18n.messages.ja = { ...Vue.prototype.i18n.messages.ja, ...{ "before_operation_record": "操作前のレコード",   "after_operation_record": "操作後のレコード",   "sql": "SQL", "manual_parameters": "手動で渡されたパラメータ", "business_object": "ビジネスオブジェクト", "difference_operation": "差分操作", "duration": "所要時間", "creation_time": "作成時間"} };
        Vue.prototype.i18n.messages.vi = { ...Vue.prototype.i18n.messages.vi, ...{ "before_operation_record": "Bản ghi trước khi hoạt động", "after_operation_record": "Bản ghi sau khi hoạt động", "sql": "SQL", "manual_parameters": "Tham số truyền vào thủ công", "business_object": "Đối tượng kinh doanh", "difference_operation": "Hoạt động khác biệt", "duration": "Thời gian thực hiện", "creation_time": "Thời gian tạo"} };
        Vue.prototype.i18n.messages.zhTW = { ...Vue.prototype.i18n.messages.zhTW, ...{ "before_operation_record": "操作前记录", "after_operation_record": "操作后记录", "sql": "SQL", "manual_parameters": "手动传入的参数", "business_object": "业务对象", "difference_operation": "差异操作", "duration": "耗时", "creation_time": "创建时间"} };
    </script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/zhCN.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/en.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/fr.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/ja.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/vi.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/zhTW.js"></script>
    <script>Vue.prototype.$baseURL = "@config?.PrefixRoute";</script>
    <script src="~/ruoveaui/xg6rvft8p/vue/axios.min.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/vue/vue-i18n.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/avue.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/avue.min.option.js"></script>
    <script>

        new Vue({
            el: '#app',
            data() {
                return {

                    name: "logdiff",
                    pageUrl: "/logdiff/pages", 

                    pageOption: {
                        total: 0,
                        page: 1,
                        pageSize: 10
                    },

                    loading: true,
                    btnLoading: false,
                    tableData: [],
                    searchParams: {},

                    searchShowBtn: false,
                    refreshBtn: false,
                    option: {
                        searchShowBtn: Permissions.avePermission(`sysLogDiff:pages`),
                        refreshBtn: Permissions.avePermission(`sysLogDiff:pages`),
                        clearBtn: Permissions.avePermission(`sysLogDiff:clear`),
                        rowKey: 'id',
                        searchMenuSpan: 8,
                        columnBtn: false,
                        searchShow: false,
                        addBtn: false,
                        menu: false,
                        editBtn: false,
                        delBtn: false,
                        viewBtn: false,
                        column: [
                            { prop: "id", label: `${this.i18n.t('primary_key')}`, search: false, hide: true, type: "number", display: false, showColumn: false, },

                            { prop: "beforeData", label: `${this.i18n.t('before_operation_record')}`, search: false, hide: false, type: "input", },
                            { prop: "afterData", label: `${this.i18n.t('after_operation_record')}`, search: false, hide: false, type: "input", },
                            { prop: "sql", label: `${this.i18n.t('sql')}`, search: false, hide: false, type: "input", },
                            { prop: "parameters", label: `${this.i18n.t('manual_parameters')}`, search: false, hide: false, type: "input", },
                            { prop: "businessData", label: `${this.i18n.t('business_object')}`, search: false, hide: false, type: "input", },
                            { prop: "diffType", label: `${this.i18n.t('difference_operation')}`, search: false, hide: false, type: "input", },
                            { prop: "elapsed", label: `${this.i18n.t('duration')}`, search: false, hide: false, type: "input", },
                            { prop: "createTime", label: `${this.i18n.t('creation_time')}`, search: true, hide: false, type: "datetime",searchRange: true, },
                        ]
                    }
                }
            },
            created() {
            },
            methods: {
                hasPermission(key) {
                    if (key === 'columnBtn' || key === 'menu' || key === 'refreshBtn') return true;
                    else return Permissions.avePermission(`${this.name}:${key}`);
                },
                getPermission(key) {
                    return Permissions.avePermission(`${key}`);
                },
                onLoad(page, done) {
                    if (this.searchParams.createTime) {
                        const [BeginTime, EndTime] = this.searchParams.createTime
                        var data = { ...page, ...this.searchParams };
                        data.BeginTime = BeginTime;
                        data.EndTime = EndTime;
                    }
                    else {
                        var data = { ...page, ...this.searchParams };
                    }
                    this.$http.post(`${this.pageUrl}`, data).then((res) => {
                        this.tableData = res.rows;
                        this.pageOption.total = res.totalRows;
                        this.loading = false;
                        if (done) { done(); }
                    }).catch(e => {
                        this.loading = false;
                        console.log(e);
                    });
                },
                searchChange(params, done) {
                    this.searchParams = params;
                    this.pageOption.page = 1;
                    this.onLoad(this.pageOption, done);
                },
                resetChange(item) {
                    this.searchParams = item;
                    this.pageOption.page = 1;
                    this.onLoad(this.pageOption);
                },
                refreshChange() { this.onLoad(this.pageOption); },
                handleDeleteAll() {
                    this.$confirm(this.i18n.t('confirmdelete'), this.i18n.t('tips'), { confirmButtonText: this.i18n.t('determine'), cancelButtonText: this.i18n.t('cancel'), type: 'error', customClass: "elmessagebox" }).then(() => {
                        this.$http.post("/logdiff/clear").then((res) => {
                            if (!res) {
                                this.$message({ message:`${this.i18n.t('submit_success')}`, center: true, type: 'success' });
                                this.onLoad();
                            }
                        });
                    }).catch(_ => { console.info(_); })
                },
            }
        });
    </script>
</body>
</html>